package com.dkts.oil.converter;

import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.opengis.geometry.BoundingBox;
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;

public class BoundingBoxUtil {
    public static BoundingBox getBoundingBox(Geometry geometry){
        Envelope envelope= geometry.getEnvelopeInternal();
        double minLon = envelope.getMinX();
        double maxLon = envelope.getMaxX();
        double minLat = envelope.getMinY();
        double maxLat = envelope.getMaxY();
        return getBoundingBox(minLon,maxLon,minLat,maxLat);
    }
    /**
     *  double minLon = Collections.min(lonList);
     *         double maxLon = Collections.max(lonList);
     *         double minLat = Collections.min(latList);
     *         double maxLat = Collections.max(latList);
     * @return
     */
   public static BoundingBox getBoundingBox(double minLon,double maxLon,double minLat,double maxLat){

       BoundingBox boundingBox= new BoundingBox() {
           @Override
           public CoordinateReferenceSystem getCoordinateReferenceSystem() {
               return null;
           }

           @Override
           public int getDimension() {
               return 0;
           }

           @Override
           public DirectPosition getLowerCorner() {
               return null;
           }

           @Override
           public DirectPosition getUpperCorner() {
               return null;
           }

           @Override
           public double getMinimum(int i) throws IndexOutOfBoundsException {
               return 0;
           }

           @Override
           public double getMaximum(int i) throws IndexOutOfBoundsException {
               return 0;
           }

           @Override
           public double getMedian(int i) throws IndexOutOfBoundsException {
               return 0;
           }

           @Override
           public double getSpan(int i) throws IndexOutOfBoundsException {
               return 0;
           }

           @Override
           public void setBounds(BoundingBox boundingBox) {

           }

           @Override
           public double getMinX() {
               return minLon;
           }

           @Override
           public double getMaxX() {
               return maxLon;
           }

           @Override
           public double getMinY() {
               return minLat;
           }

           @Override
           public double getMaxY() {
               return maxLat;
           }

           @Override
           public double getWidth() {
               return 0;
           }

           @Override
           public double getHeight() {
               return 0;
           }

           @Override
           public boolean isEmpty() {
               return false;
           }

           @Override
           public void include(BoundingBox boundingBox) {

           }

           @Override
           public void include(double v, double v1) {

           }

           @Override
           public boolean intersects(BoundingBox boundingBox) {
               return false;
           }

           @Override
           public boolean contains(BoundingBox boundingBox) {
               return false;
           }

           @Override
           public boolean contains(DirectPosition directPosition) {
               return false;
           }

           @Override
           public boolean contains(double v, double v1) {
               return false;
           }

           @Override
           public BoundingBox toBounds(CoordinateReferenceSystem coordinateReferenceSystem) throws TransformException {
               return null;
           }
       };
       return boundingBox;
   }
}
